/**
 * author:Administrator
 * date:2013-5-21
 */
package com.roc.web.action.terminal;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

/**
 * 
 * @author 陈锴
 * 
 * 终端序列号添加
 * 
 * 2014-08-18
 *
 */
public class TermSnAgentSearchCondition extends BaseSearchCondition {
	

	
	private String posBrand;  //品牌
	private String posType;  //机型
	private String posName;  
	private String serialNum;
	private long agentId;    
	private String mid;
	private String tid;
	

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getOrderPartOfHQL()
	 */
	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		
		return " order by pos.pos_brand asc,pos.pos_type asc,pos.pos_name asc, pos.serial_num asc ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getRowCountHQL()
	 */
	@Override
	protected String getRowCountHQL() {//,OrgBean o  t.orgCode = o.org_code
		
		return " select count(*) from ( "
				+ " select y.serial_num,y.pos_brand,y.pos_type,y.pos_name,a.agent_id,a.is_used,a.dt_create,a.dt_lastmod from yj_pos_info y,yj_pos_agent a where a.serial_num=y.serial_num and a.pos_brand = y.pos_brand and y.is_bind='N' and a.is_used='N' "
				+ " ) pos where not exists   (select * from tbl_term_inf tt where tt.device_cd=pos.serial_num and tt.TMNL_BRAND = pos.pos_brand) ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getSearchHQL()
	 */
	@Override
	protected String getSearchHQL() {
		
		return " select serial_num,pos_brand,pos_type,pos_name,agent_id,is_used,dt_create,dt_lastmod from ( "
				+ " select y.serial_num,y.pos_brand,y.pos_type,y.pos_name,a.agent_id,a.is_used,a.dt_create,a.dt_lastmod from yj_pos_info y,yj_pos_agent a where a.serial_num=y.serial_num and a.pos_brand = y.pos_brand and y.is_bind='N' and a.is_used='N' "
				+ " ) pos where not exists  (select * from tbl_term_inf tt where tt.device_cd=pos.serial_num and tt.TMNL_BRAND = pos.pos_brand) ";
}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getWhereHQLFieldBeanList()
	 */
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		
		
		if (Constance.isNotEmpty(posBrand) && !posBrand.equals("-1")) {
			filedBeanList.add(new WhereHQLFieldBean("pos.pos_brand", posBrand.trim(), "=", false));
		}
		if (Constance.isNotEmpty(posType) && !posType.equals("-1")) {
			filedBeanList.add(new WhereHQLFieldBean("pos.pos_type", posType.trim(), "=", false));
		}
		if (Constance.isNotEmpty(posName) && !posName.equals("-1")) {
			filedBeanList.add(new WhereHQLFieldBean("pos.pos_name", posName.trim(), "=", false));
		}
		if (Constance.isNotEmpty(serialNum)) {
			filedBeanList.add(new WhereHQLFieldBean("pos.serial_num", serialNum.trim(), "=", false));
		}
		if(agentId!=0){
			filedBeanList.add(new WhereHQLFieldBean("pos.agent_id", agentId, "=", false));
		}
		return filedBeanList;
	}


	

	public String getPosBrand() {
		return posBrand;
	}

	public void setPosBrand(String posBrand) {
		this.posBrand = posBrand;
	}

	public String getPosType() {
		return posType;
	}

	public void setPosType(String posType) {
		this.posType = posType;
	}

	public String getPosName() {
		return posName;
	}

	public void setPosName(String posName) {
		this.posName = posName;
	}

	public long getAgentId() {
		return agentId;
	}

	public void setAgentId(long agentId) {
		this.agentId = agentId;
	}

	public String getSerialNum() {
		return serialNum;
	}

	public void setSerialNum(String serialNum) {
		this.serialNum = serialNum;
	}

	public String getMid() {
		return mid;
	}

	public void setMid(String mid) {
		this.mid = mid;
	}

	public String getTid() {
		return tid;
	}

	public void setTid(String tid) {
		this.tid = tid;
	}
	
}
